﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using T4Template.Bl;
using T4Template.Dto;
using T4Template.Model;

namespace T4Template.Controller
{
    class CodeTemplateController
    {
        private CodeTemplateBL codeTemplateBL;

        public CodeTemplateController()
        {
            codeTemplateBL = new CodeTemplateBL();
         }

        public CreateTemplateResultModel CreateTemplate(CreateCodeTemplateModel model)
        {
            CreateTemplateResultModel resultModel = new CreateTemplateResultModel();

            CreateCodeTemplateDto dto = new CreateCodeTemplateDto();
            dto.Name = model.Name;
            dto.CodeType = model.CodeType;
            dto.PatternType = model.PatternType;
            dto.NewVersion = model.NewVersion;
            dto.Comment = model.Comment;
            dto.TemplateNameSpaceList = model.TemplateNameSpaceList;
            dto.TemplateClassNameList = model.TemplateClassNameList;

            ActionResultDto<CodeTemplateDto> resultDto = codeTemplateBL.Create(dto);
            resultModel.Status = resultDto.Status;
            resultModel.ErrorMessage = resultDto.ErrorMessage;

            return resultModel;
        }
    }
}
